package utils;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

/**
 * @version 1.0
 * 功能目的描述 ：用于        实现信道channel ========>>>>>>>>>>>
 * @author： pang-yun
 * @date： 2021-07-28 20:42
 */
//工具类   连接工厂 创建信道的工具类
public class RabbitMQUtils {

    public static Channel getChannel() throws IOException, TimeoutException {
        ConnectionFactory mqFactory = new ConnectionFactory();
        mqFactory.setHost("127.0.0.1");
        mqFactory.setUsername("pangyun");
        mqFactory.setPassword("1234");
        Connection connection = mqFactory.newConnection();
        Channel channel = connection.createChannel();

        return channel;
    }
}
